package com.truesai.entities.stock;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import com.truesai.entities.production.Production;
/**
 * 产品库存总表<br/>
 * 需求分析<br/>
 * <strong>唯一性:</strong>产品id<br/>
 * 该表主要存放产品的库存总数量。
 * @author XuLian
 *
 */
@Entity
@NamedQueries(
{
        @NamedQuery(name = Stock.ALL, query = "Select s from Stock s"),
        @NamedQuery(name = Stock.BY_PRODUCTION, query = "Select s from Stock s where s.production = :production"),
        @NamedQuery(name = Stock.BY_ID, query = "Select s from Stock s where s.id = :id") })
@Table(name = "Stocks")
public class Stock {
	
	public static final String ALL = "Stock.all";

    public static final String BY_PRODUCTION = "Stock.byProduction";

    public static final String BY_ID = "Stock.byId";
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    /**产品*/
    @ManyToOne
    private Production production;
    
    /**总量*/
    @Column
    private BigDecimal totalAmount;
    
    public Stock() {}
    
    public Stock(Production production, BigDecimal totalAmount) {
    	this.production = production;
    	this.totalAmount = totalAmount;
    }

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Production getProduction() {
		return production;
	}

	public void setProduction(Production production) {
		this.production = production;
	}

	public BigDecimal getTotalAmount() {
		return totalAmount;
	}

	public void setTotalAmount(BigDecimal totalAmount) {
		this.totalAmount = totalAmount;
	}
    
	
}
